<?php

namespace Modules\Backend\Auth;

use App\Http\Requests\Backend\AdminRegisterRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Events\Registered;

trait RegistersUsers
{
    use RedirectsUsers;


    public function showRegistrationForm()
    {
        return view('backend::auth.register');
    }


    public function register(AdminRegisterRequest $request)
    {

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
                        ?: redirect($this->redirectPath());
    }

    protected function guard()
    {
        return Auth::guard("backend");
    }

    /**
     * @Author: hzwlxy
     * @Email: 120235331@qq.com
     * @Date: 2019/7/1 14:42
     * @Description:注册之后执行
     * @param Request $request
     * @param $user
     * @return bool
     */
    protected function registered(Request $request, $user)
    {
         return false;
    }
}
